﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion


#region Usings

using System;
using System.Windows;
using Microsoft.Surface.Presentation;
using ScrumTable.BL.DM.DataManagement;
using ScrumTable.UI.View.Controls;
using ScrumTable.UI.View.Extension;
using ScrumTable.UI.ViewModel;

#endregion

namespace ScrumTable.UI.View.WinTouch.UserControls
{
    /// <summary>
    /// Interaction logic for MemberControl.xaml
    /// </summary>
    public partial class MemberControl : IDropUserControl
    {
        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------

        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------
        
        #endregion

        #region Constructors / Destructor
        /// <summary>
        /// Initializes a new instance of the <see cref="MemberControl"/> class.
        /// </summary>
        public MemberControl()
        {
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
                InitializeComponent();
        }
        #endregion

        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------

        public FrameworkElement GetRootControl
        {
            get { return DropRootControl; }
        }

        public bool ShowIconWithbackground
        {
            get { return true; }
        }

        public CanDropResult CanDrop(object objectToDrop)
        {
            return this.ConvertBoolToEnum(objectToDrop is IScrumItemViewModel<DomainBase>);
        }

        #endregion

        #region Events
        //--------------------------------------------------------------------
        // Events
        //--------------------------------------------------------------------

        private void OnMemberDrop(object sender, SurfaceDragDropEventArgs e)
        {
            if (e.Cursor.Data is IScrumItemViewModel<DomainBase>)
                ((IScrumItemViewModel<DomainBase>)e.Cursor.Data).AssignedMember = (MemberViewModel)this.DataContext;
            else
                e.Effects = DragDropEffects.None;
        }

        private void OnMemberPreviewQueryTarget(object sender, QueryTargetEventArgs e)
        {
            if ((e.Cursor.Data is IScrumItemViewModel<DomainBase>)) return;

            e.UseDefault = false;
            e.ProposedTarget = null;
            e.Handled = true;
        }

        #endregion
      
    }
}
